<template>
	<view class="mask" v-if="show" @click="close">
		<view class="content" @click.stop="">
			<view class="title">
				{{ title }}
				<span class="close" @click.stop="close">
					×
				</span>
			</view>
			<view class="items">
				<radio-group @change="radioChange">
					<label v-for="(item, index) in list" :key="index">
						<view class="item flexR">
							<view>{{item.name}}</view>
							<radio :value="''+index" :checked="index === current" />
						</view>
					</label>
				</radio-group>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "ChangeSelect",
		props: {
			show: {
				type: Boolean,
				default: false
			},
			title: {
				type: String,
				default: '切换'
			},
			list: {
				type: Array,
				default: () => {
					return []
				}
			},
			current: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				// current: 1
			};
		},
		methods: {
			radioChange: function(evt) {
				this.$emit('updateCurrent', parseInt(evt.detail.value))
			},
			close() {
				this.$emit('close', false)
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.mask {
		position: absolute;
		z-index: 99;
		background-color: rgba(0, 0, 0, 0.42);
		height: 100%;
		width: 100vw;
		top: 0;
		left: 0;

		.content {
			position: absolute;
			bottom: 0;
			width: 100vw;
			border-radius: 24upx 24upx 0 0;
			background-color: #FFF;
			padding: 32upx;

			.title {
				text-align: center;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 36upx;
				color: rgba(0, 0, 0, 0.8);

				.close {
					float: right;
				}
			}

			.items {
				.item {
					justify-content: space-between;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 28upx;
					color: rgba(0, 0, 0, 0.7);
					line-height: 100upx;
					padding-left: 32upx;
				}
			}
		}
	}
</style>